package com.bs.web.rest;


import com.bs.domain.ServiceInfo;
import com.bs.service.QuestionCountService;
import com.bs.service.SlowSqlTop10Service;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "questionCount")
@RestController
@RequestMapping("/api/dashboard")
public class QuestionCountResource {

    @Autowired
    QuestionCountService questionCountService;
    @Autowired
    SlowSqlTop10Service slowSqlTop10Service;

    @GetMapping("/slowServiceOrCommTop10")
    public List<ServiceInfo> slowServiceOrCommTop10Resource(@RequestParam("logmsg") String logmsg,
                                                            @RequestParam("startTime") String startTime,
                                                            @RequestParam("endTime") String endTime,
                                                            @RequestParam("partition") String partition,
                                                            @RequestParam("code") String code,
                                                             @RequestParam("active") String active
    ) {
        List<ServiceInfo> serviceInfos = questionCountService.slowServiceOrCommTop10Resource(partition, logmsg, startTime, endTime,code,active);
        return serviceInfos;
    }


    @GetMapping("/slowSqlTop10")
    public List<ServiceInfo> slowSqlTop10Resource(@RequestParam("uid") String uid,
                                                  @RequestParam("startTime") String startTime,
                                                  @RequestParam("endTime") String endTime,
                                                  @RequestParam("partition") String partition,
                                                  @RequestParam("code") String code,
                                                  @RequestParam("active") String active
    ) {
        return slowSqlTop10Service.slowSqlTop10Resource(partition, uid, startTime, endTime, code,active);
    }
}
